package com.sxran.im.handler;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sxran.im.bean.ImException;
import com.sxran.im.controller.ImController;
import com.sxran.im.dao.ImGroupMapper;
import com.sxran.im.dao.ImUserGroupMapper;
import com.sxran.im.dao.ImUserMapper;
import com.sxran.im.info.ImGroup;
import com.sxran.im.info.ImUser;
import com.sxran.im.info.ImUserGroup;
import com.sxran.im.service.UserGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class UpdateGroupInfoCmdHandler extends AbstractCmdHandler<ImGroup>{
    @Resource
    private ImGroupMapper imGroupMapper;
    @Resource
    private UserGroupService userGroupService;

    @Override
    public Object doBeanService(ImGroup json) {
        String groupId = json.getGroupId();
        // 获取群聊的用户组信息。
        if (userGroupService.isAdmin(groupId)) {
            imGroupMapper.updateById(json);
        }else{
            throw new ImException("您不是管理员",500);
        }
        return json;
    }
}
